package org.example.demo.controller.userController;

import io.swagger.annotations.ApiOperation;
import org.example.demo.common.api.CommonResult;
import org.example.demo.service.userService.UserHomeService;
import org.example.mbg.model.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 首页推荐商品
 */
@Controller
public class SearchProductController {
    @Autowired
    private UserHomeService productService;

    @ApiOperation("根据商品名称模糊查询")
    @RequestMapping(value = "/user/search",method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<List<Product>> SearchProduct(@RequestParam("product_name") String product_name){
        List<Product> products=productService.findProduct(product_name);
        return CommonResult.success(products);
    }
}
